package com.scau.vo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * SaleOrderItem entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sale_order_item", catalog = "db_hairdressingpos")
public class SaleOrderItem implements java.io.Serializable {

	// Fields

	private Integer id;
	private SaleOrder saleOrder;
	private Product product;
	private Service service;
	private String itemName;
	private String productName;
	private String quantity;
	private String salePrice;
	private String subTotal;

	// Constructors

	/** default constructor */
	public SaleOrderItem() {
	}

	/** minimal constructor */
	public SaleOrderItem(SaleOrder saleOrder, String quantity,
			String salePrice, String subTotal) {
		this.saleOrder = saleOrder;
		this.quantity = quantity;
		this.salePrice = salePrice;
		this.subTotal = subTotal;
	}

	/** full constructor */
	public SaleOrderItem(SaleOrder saleOrder, Product product, Service service,
			String itemName, String productName, String quantity,
			String salePrice, String subTotal) {
		this.saleOrder = saleOrder;
		this.product = product;
		this.service = service;
		this.itemName = itemName;
		this.productName = productName;
		this.quantity = quantity;
		this.salePrice = salePrice;
		this.subTotal = subTotal;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "saleOrderNo", nullable = false)
	public SaleOrder getSaleOrder() {
		return this.saleOrder;
	}

	public void setSaleOrder(SaleOrder saleOrder) {
		this.saleOrder = saleOrder;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "productId")
	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "itemId")
	public Service getService() {
		return this.service;
	}

	public void setService(Service service) {
		this.service = service;
	}

	@Column(name = "itemName")
	public String getItemName() {
		return this.itemName;
	}

	public void setItemName(String itemName) {
		this.itemName = itemName;
	}

	@Column(name = "productName")
	public String getProductName() {
		return this.productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	@Column(name = "quantity", nullable = false)
	public String getQuantity() {
		return this.quantity;
	}

	public void setQuantity(String quantity) {
		this.quantity = quantity;
	}

	@Column(name = "salePrice", nullable = false)
	public String getSalePrice() {
		return this.salePrice;
	}

	public void setSalePrice(String salePrice) {
		this.salePrice = salePrice;
	}

	@Column(name = "subTotal", nullable = false)
	public String getSubTotal() {
		return this.subTotal;
	}

	public void setSubTotal(String subTotal) {
		this.subTotal = subTotal;
	}
	
	@Override
	public String toString() {
		return "{\"id\":" + id 
				+ ", \"saleOrderId\":" + saleOrder.getId()
				+ ", \"productId\":" + product.getId()
				+ ", \"productName\":" + "\"" + product.getName() + "\""
				+ ", \"serviceId\":" + service.getId()
				+ ", \"serviceName\":" + "\"" + service.getName() + "\""
				+ ", \"quantity\":" + "\"" +quantity + "\"" 
				+ ", \"salePrice\":" + "\"" +salePrice + "\""
				+ ", \"subTotal\":" + "\"" +subTotal + "\""
				+ "}";
	}

}